package com.itheima.treemap;

import java.util.*;

public class TreeMapDemo {
    public static void main(String[] args) {
        TreeMap<Student,String> ts = new TreeMap(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                int result=Integer.parseInt(o1.getAge())-Integer.parseInt(o2.getAge());
                return result==0?o1.getName().compareTo(o2.getName()):result;
            }
        });
        Student student1=new Student("yy","24");
        Student student2=new Student("yyds","18");
        Student student3=new Student("san","33");
        ts.put(student1,"安徽");
        ts.put(student2,"beijing");
        ts.put(student3,"shanghai");
        Set<Student> students = ts.keySet();
        for (Student student : students) {
            System.out.println(student+ts.get(student));

        }
    }
}
